
import defaultData from "./data";
import Props from "../base/Props";
import { WeaSelect, WeaBrowser, WeaLocaleProvider } from 'ecCom';
import { Row } from 'antd';
import { selectType } from '../../../../../constants/form';
import fillin from '../../../../../apis/fillin';

const { CURRENT, APPOINT, EMPTY } = selectType;
const getLabel = WeaLocaleProvider.getLabel;

export default class SingleBrowserProps extends Props {

  refsDefaultValue = () => {
    return { defaultValue: '' }
  }

  renderDefaultValue() {
    const { data } = this.props;
    const { type: t, defaultValue: dv } = defaultData;
    const { type = t, defaultValue = dv } = data;
    const options = [
      {
        showname: '',
        key: EMPTY
      },
      {
        showname: getLabel(384035, '当前人员'),
        key: CURRENT,
      },
      {
        showname: getLabel(514999, '指定人员'),
        key: APPOINT
      }
    ];
    
    return (
      <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@6k1dp7`}>
        <label>{getLabel(502451, '默认值')}</label>
        <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@c378c6`}
          style={{ minWidth: '100%' }}
          value={type}
          options={options}
          onChange={this.handlePropChange('type:(refs=refsDefaultValue)')}
        />
        {
          type === APPOINT && 
          <div className='mt20'>
            <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@yle371`}>
              <label>{getLabel(502424, '请选择人员')}</label>
              <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@kmizka`}
                title={getLabel('513623', '人力资源')}
                type={1}
                textDecoration={true}
                replaceDatas={[defaultValue]}
                inputStyle={{ width: '100%' }}
                isSingle={true}
                onChange={(ids, names, datas) => {
                  this.handlePropChange('defaultValue')({id: ids, name: names})
                }}
              />
            </Row>
          </div>
        }
      </Row>
    );
  }

  renderTipContent() {
    return (
      <Row ecId={`${this && this.props && this.props.ecId || ''}_Row@wxbu2p`}>
        <label className='browserHrm-tip'>
          <span>{getLabel(526737,'当前插件在填报时只有OA用户才会显示')}</span>
        </label>
      </Row>
    );
  }
}

SingleBrowserProps.defaultProps = {
  data: defaultData
};